//
//  Camera.hpp
//  RayTracer
//
//  Created by 俞云康 on 2/15/16.
//  Copyright © 2016 yushroom. All rights reserved.
//

#ifndef Camera_hpp
#define Camera_hpp

#include "Math.hpp"
#include "Ray.hpp"

class Params;

class Camera {
public:
    float3 position;
    float3 direction;   // z ais
    float3 cx;          // x axis
    float3 cy;          // y axis
    
    Camera() = default;
    
    // aspect: window width / height
    // fov: in radians
    Camera(float3 position, float3 direction, float aspect, float fov);
    
    static Camera create(const Params& params, float aspect);
    
    // u = x / width, v = y / height
    inline Ray ray_at(float u, float v) const {
        float3 dir = cx*u + -cy*v + direction;
        return Ray(position, Normalize(dir));
    }
};


#endif /* Camera_hpp */
